package com.ys.cloud.nacos.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * <p>@description: </p>
 *
 * @author yangshuang
 * @version 1.0
 * @date 2019/6/9 13:34
 */
@RestController
public class EchoController {

    @Autowired
    private RestTemplate restTemplate;


    @GetMapping(value = "/consumer/calculate/divide/{a}/{b}")
    public String echo(@PathVariable String a, @PathVariable String b) {

//        Map<String, Object> uriVariable = new HashMap<>();
//        uriVariable.put("a", a);
//        uriVariable.put("b", b);
//        String reqStr = String.format("http://dubbo-spring-cloud-rest-provider/divide-test");
        String reqStr = String.format("http://dubbo-spring-cloud-rest-provider//divide?a=%s&b=%s", a, b);
        return restTemplate.getForObject(reqStr, String.class);
    }
}
